package com.vivi.codereview.tools;

public class MavenProject {

  private static final String FORMAT = "{0}.{1}";

  private String groupId;

  private String artifactId;

  public MavenProject(String groupId, String artifactId) {
    super();
    this.groupId = groupId;
    this.artifactId = artifactId;
  }

  /**
   * @return the groupId
   */
  protected String getGroupId() {
    return groupId;
  }

  /**
   * @param groupId the groupId to set
   */
  protected void setGroupId(String groupId) {
    this.groupId = groupId;
  }

  /**
   * @return the artifactId
   */
  protected String getArtifactId() {
    return artifactId;
  }

  /**
   * @param artifactId the artifactId to set
   */
  protected void setArtifactId(String artifactId) {
    this.artifactId = artifactId;
  }

  /* (non-Javadoc)
   * @see java.lang.Object#hashCode()
   */
  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((artifactId == null) ? 0 : artifactId.hashCode());
    result = prime * result + ((groupId == null) ? 0 : groupId.hashCode());
    return result;
  }

  /* (non-Javadoc)
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    MavenProject other = (MavenProject)obj;
    if (artifactId == null) {
      if (other.artifactId != null)
        return false;
    }
    else if (!artifactId.equals(other.artifactId))
      return false;
    if (groupId == null) {
      if (other.groupId != null)
        return false;
    }
    else if (!groupId.equals(other.groupId))
      return false;
    return true;
  }

  /* (non-Javadoc)
   * @see java.lang.Object#toString()
   */
  @Override
  public String toString() {
    return "MavenProject [groupId=" + groupId + ", artifactId=" + artifactId + "]";
  }

  public String getFormatted() throws Exception {
    return Utils.formatString(FORMAT, groupId, artifactId);
  }




}
